﻿namespace ClearLines.Bumblebee.Tests

open ClearLines.Bumblebee
open System
open NUnit.Framework
open FsUnit

[<TestFixture>]
type ProblemTests() =

   [<Test>]
   member test.``Problem using Func constructor should use the Funcs``() =

      // Arrange
      let data = "DATA"
      let generator = new Func<Random, string>(fun rng -> data + "GENERATOR")
      let mutator = new Func<string, Random, string>(fun solution rng -> solution + "MUTATOR")
      let evaluator = new Func<string, double>(fun (input) -> 42.0)

      let rng = new Random()
      // Act
      let problem = new Problem<string>(generator, mutator, evaluator)

      // Assert
      problem.Generate (rng)  |> should equal "DATAGENERATOR"
      problem.Mutate rng "SOLUTION" |> should equal "SOLUTIONMUTATOR"
      problem.Evaluate "SOLUTION" |> should equal 42.0